package nl.hva.three2learn.model;

import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "event")
public class Event {

	public static final String NEW_COURSE_TITLE_RPOPERTY = "event.course.new.title";
	public static final String NEW_COURSE_DESCRIPTION_PROPERTY = "event.course.new.descrtiption";
	
	public static final String NEW_CHAPTER_TITLE_PROPERTY = "event.chapter.new.title";
	
	public static final String NEW_TOPIC_TITLE_PROPERTY = "event.topic.new.title";
	
	public static final String LIVE_SESSION_STARTED_PROPERTY = "event.livesession.started";
	
	@Id
	@GeneratedValue
	@Column(name = "id")
	private long id;
	
	@Column(name = "title")
	private String title;
	
	@Column(name = "description")
	private String description;
	
	@Column(name = "url")
	private String url;
	
	@Column(name = "creation_date")
	private Date creationDate;
	
	@Column(name = "params")
	private String[] params;
	
	public Event() { }
	
	public Event(String title, String description, String url) {
		this.title = title;
		this.description = description;
		this.url = url;
		this.creationDate = Calendar.getInstance(Locale.getDefault()).getTime();
	}

	public Event(String title, String description) {
		this(title, description, null);
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	/**
	 * Relative url that the event belongs to.
	 * @return
	 */
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public String[] getParams() {
		return params;
	}

	public void setParams(String[] params) {
		this.params = params;
	}

	@Override
	public String toString() {
		return "Event [ title=" + title + ", " +
				"description=" + description + ", " +
				"creationDate=" + creationDate +
				" ]";
	}
}
